<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>学生列表</title>
</head>

<body>
    <table id="list" border="1">
        <tr>
            <th>姓名</th>
            <th>手机号</th>
            <th>身份证号</th>
        </tr>

    </table>
</body>

<script id="temp" type="text/html">
    {{each xxx}}
    <tr>
        <td>{{$value.name}}</td>
        <td>{{$value.mobile}}</td>
        <td>{{$value.id_card}}</td>
    </tr>
    {{/each}}
</script>

<script src="/static/js/template-web.js"></script>
<script>

    fetch('/student')
        .then(res => {
            return res.json();
        })
        .then(data => {
            if (data.code) {
                alert('没有信息');
            } else {
                let str = template('temp', {xxx: data.data})
                let p = document.getElementById('list');
                p.innerHTML = p.innerHTML + str;
            }
        });


</script>

</html>